package com.lantosec.hmrp.modules.uploads.vo;

import com.lantosec.hmrp.core.config.InitDataListener;
import com.lantosec.hmrp.core.mvc.BaseVO;
import com.lantosec.hmrp.modules.uploads.entity.SysUploads;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;

/**
 * <p>
 * 系统上传数据 VO对象
 * </p>
 *
 * @author AutoCode
 * @since 2020-02-19
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "SysUploads对象", description = "系统上传数据")
public class SysUploadsVO extends BaseVO<SysUploads> {
    private static final long serialVersionUID = 1L;


    public SysUploadsVO(SysUploads entity) {
        this.uploadId = entity.getUploadId();
        this.uploadTitle = entity.getUploadTitle();
        this.mediaType = entity.getMediaType();
        this.uploadTime = entity.getUploadTime();
        this.fileSize = entity.getFileSize();
        this.savePath = entity.getSavePath();
        this.fileName = entity.getFileName();
        this.fileSuffix = entity.getFileSuffix();
        this.thumbnailPath = entity.getThumbnailPath();
        this.fileUrl = InitDataListener.uploadsUrl + savePath;
        this.localUrl = InitDataListener.rootPath + savePath;//读取本地下的文件
        this.thumbnailUrl = InitDataListener.uploadsUrl + thumbnailPath;
    }

    @Override
    public SysUploads convertToEntity() {
        return new SysUploads(this);
    }


    @ApiModelProperty(value = "ID")
    private String uploadId;

    @ApiModelProperty(value = "上传标题")
    private String uploadTitle;

    @ApiModelProperty(value = "上传媒体类型(10图片 20文件)")
    private Integer mediaType;

    @ApiModelProperty(value = "上传时间")
    private Date uploadTime;

    @ApiModelProperty(value = "上传文件大小(KB)")
    private Long fileSize;

    @ApiModelProperty(value = "文件保存路径")
    private String savePath;

    @ApiModelProperty(value = "文件名")
    private String fileName;

    @ApiModelProperty(value = "文件后缀名")
    private String fileSuffix;

    @ApiModelProperty(value = "缩略图路径")
    private String thumbnailPath;

    @ApiModelProperty(value = "文件访问路径")
    private String fileUrl;

    @ApiModelProperty(value = "文件访问本地路径")
    private String localUrl;

    @ApiModelProperty(value = "缩略图访问路径")
    private String thumbnailUrl;
}
